home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doClearKeyArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  6.1 KB  |  200 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  10 Aug 98
  22. //  Author:         mw
  23. //
  24. //  Description:
  25. //        doClearKeyArgList is the actual proc that is executed from the
  26. //    Edit->Keys->Delete Keys option box or menu
  27. //
  28. //  Input Arguments:
  29. //    $version: The version of this option box.  Used to know how to 
  30. //    interpret the $args array.
  31. //        "1" : $whichRange, $timeRange, $option, $hierarchy,
  32. //                $doControlPoints, $doShapes, $useChannelBox,
  33. //                $allAnimCurves, $selectionConnection
  34. //        "2" : $options
  35. //        "3" : $fromGraphEditor, $doDrivenChannels
  36. //    
  37. //    $args
  38. //    Version 1
  39. //    [0]        $whichRange                1 : time range all
  40. //                                    2 : use playback range
  41. //                                    3 : use $timeRange
  42. //    [1]        $timeRange                startTime:endTime
  43. //    [2]        $option                    keys
  44. //                                    curveCollapse
  45. //                                    curveConnect
  46. //    [3]        $hierarchy                1 : none
  47. //                                    2 : below
  48. //    [4]        $doControlPoints        0 / 1
  49. //    [5]        $doShapes                0 / 1
  50. //    [6]        $useChannelBox            0 / 1
  51. //    [7]        $allAnimCurves            0 / 1
  52. //    [8]        $selectionConnection    name of selection connection to use
  53. //                                    unless $options has "bufferCurve" in which
  54. //                                    case this is the name of the editor
  55. //    [9]        unused                    0 / 1
  56. //
  57. //    Version 2
  58. //    [10]    $options                a ':' delimited list of options
  59. //                                    noOptions        an empty placeholder
  60. //                                    bufferCurve        create buffer curves
  61. //    Version 3
  62. //    [11]    $fromGraphEditor        0 / 1 
  63. //    [12]    $doDrivenChannels        0 / 1 
  64. //
  65. //  Return Value:
  66. //      The number of curves from which keys were cut.
  67. //
  68. global proc int doClearKeyArgList( string $version, string $args[] )
  69. {
  70.     int        $versionNum                = $version;
  71.  
  72.     int        $whichRange                = $args[0];
  73.     string    $timeRange                = $args[1];
  74.     string    $option                    = $args[2];
  75.     string    $hierarchy                = $args[3];
  76.     int        $doControlPoints        = $args[4];
  77.     int        $doShapes                = $args[5];
  78.     int        $useChannelBox            = $args[6];
  79.     int        $allAnimCurves            = $args[7];
  80.     string    $selectionConnection    = $args[8];
  81.     int        $unused                    = $args[9];
  82.     string    $options                = $versionNum >= 2 ? $args[10] : "noOptions";
  83.     int     $fromGraphEditor        = $versionNum >= 3 ? $args[11] : "0";
  84.     int     $doDriven                = $versionNum >= 3 ? $args[12] : "1";
  85.  
  86.     string $cmd = "cutKey -clear ";
  87.  
  88.     string $realConnection = $selectionConnection;
  89.  
  90.     // Check for the bufferCurve option
  91.     //
  92.     if (match ("bufferCurve", $options) == "bufferCurve") {
  93.         $realConnection = `editor -query -mainListConnection $selectionConnection`;
  94.         // Check to see if we need to create buffer curves
  95.         //
  96.         if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
  97.             $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd;
  98.         }
  99.     }
  100.  
  101.     // Get the target objects
  102.     //
  103.     string $members = expandSelectionConnection ($realConnection);
  104.  
  105.     int $needOption = true;
  106.     if( $whichRange == 1 ) {
  107.         $timeRange = ":";
  108.         $needOption = false;
  109.     } else if( $whichRange == 2 ) {
  110.         $timeRange = ( `playbackOptions -q -min` + ":" + 
  111.                        `playbackOptions -q -max` );
  112.     }
  113.  
  114.     // Check to see if a time range has been specified.  If no time range,
  115.     // then we don't add the option, since we're doing all the keyframes
  116.     // and an option makes no sense.
  117.     //
  118.     int $keys = `keyframe -sl -q -kc`;
  119.     if( !$fromGraphEditor || ( $keys == 0 ) ) {
  120.         $cmd = ( $cmd + "-time \"" + $timeRange + "\" " );
  121.  
  122.         if( $fromGraphEditor || $doDriven ) {
  123.             $cmd = ( $cmd + "-float \"" + $timeRange + "\" " );
  124.         }
  125.         
  126.         // If there's a time specified, always add the option
  127.         //
  128.         if( $needOption ) {
  129.             $cmd = ( $cmd + "-option " + $option + " " );
  130.         }
  131.     }
  132.     
  133.     if( !$fromGraphEditor && $allAnimCurves ) {
  134.         int     $i;
  135.  
  136.         string     $curves[] = `ls -type animCurveTL`;
  137.         for( $i = 0; $i < size( $curves ); $i++ ) {
  138.             $cmd = ( $cmd + " " + $curves[$i] );
  139.         }
  140.         $curves = `ls -type animCurveTU`;
  141.         for( $i = 0; $i < size( $curves ); $i++ ) {
  142.             $cmd = ( $cmd + " " + $curves[$i] );
  143.         }
  144.         $curves = `ls -type animCurveTA`;
  145.         for( $i = 0; $i < size( $curves ); $i++ ) {
  146.             $cmd = ( $cmd + " " + $curves[$i] );
  147.         }
  148.         $curves = `ls -type animCurveTT`;
  149.         for( $i = 0; $i < size( $curves ); $i++ ) {
  150.             $cmd = ( $cmd + " " + $curves[$i] );
  151.         }
  152.     }
  153.     else if( !$fromGraphEditor && ($useChannelBox == 1 ) ) {
  154.         string $syntax[] = keySetOptionBoxCommon( { "clearKey", "unknown", 
  155.                                                     "channelBoxSyntax" } );
  156.         if( size( $syntax[0] ) == 0 ) {
  157.             $cmd = "";
  158.             warning( "No channels selected in channel box" );
  159.         } else {
  160.             $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " );
  161.  
  162.             $cmd = $cmd + $syntax[0];
  163.         }
  164.     }
  165.     else if( $members != "" ) {
  166.         // Only add the selection connection to the cmd if
  167.         // there are NO active keys (in the graph editor),
  168.         // or we're not called from the graphEditor.
  169.         //
  170.         if( $keys == 0 || !$fromGraphEditor ) {
  171.             if ($members == "{}") {
  172.                 $cmd = "";
  173.                 warning ("No objects selected to delete keys");
  174.             }
  175.             else {
  176.                 $cmd = ($cmd + 
  177.                     "-hierarchy " + $hierarchy + " " +
  178.                     "-controlPoints " + $doControlPoints + " " +
  179.                     "-shape " + $doShapes + " " +
  180.                     $members
  181.                  );
  182.             }
  183.         }
  184.     } 
  185.     else {
  186.         $cmd = ( $cmd + 
  187.                  "-animation objects " +  
  188.                  "-hierarchy " + $hierarchy + " " +
  189.                  "-controlPoints " + $doControlPoints + " " +
  190.                  "-shape " + $doShapes + " " );
  191.     }
  192.     
  193.     if( $cmd == "" ) {
  194.         return 0;
  195.     } else {
  196.         return evalEcho( $cmd );
  197.     }
  198. }
  199.  
  200.